﻿using System;
using System.CodeDom;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DevExpress.Web.ASPxEditors;
using Microsoft.Ajax.Utilities;
using Web;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Web.UserControls
{
    public partial class ucAccessControl : System.Web.UI.UserControl
    {
       protected void Page_Init(object sender, System.EventArgs e)
        {
            //Me.Enabled = True
           /*
           AddClick += delegate { btnAdd_Click(sender,e );};
           EditClick += delegate { btnEdit_Click(sender, e); };
           CopyClick += delegate { btnCopy_Click(sender, e); };
           DeleteClick += delegate { btnDelete_Click(sender, e); };
           SearchClick += delegate { btnSearch_Click(sender, e); };
           */
           
        }
  
        public ucAccessControl()
	    {
		    Init += Page_Init;//InitializeComponent();
        }
    
        // Page load
        protected void Page_Load(object sender, EventArgs e)
        {
            btnAdd.Click += new EventHandler(btnAdd_Click);
            btnEdit.Click += new EventHandler(btnEdit_Click);
            btnCopy.Click += new EventHandler(btnCopy_Click);
            btnDelete.Click += new EventHandler(btnDelete_Click);
            btnSearch.Click += new EventHandler(btnSearch_Click);
        }



        #region | ClientID |
        public string AddClientID
        {
            get { return btnAdd.ClientID; }
        }
        public string EditClientID
        {
            get { return btnEdit.ClientID; }
        }
        public string CopyClientID
        {
            get { return btnCopy.ClientID; }
        }
        public string DeleteClientID
        {
            get { return btnDelete.ClientID; }
        }
        public string SearchClientID
        {
            get { return btnSearch.ClientID; }
        }
        #endregion

        #region |  Attributes |

        public AttributeCollection AddAttributes
        {
            get { return btnAdd.Attributes; }
        }

        public AttributeCollection EditAttributes
        {
            get { return btnEdit.Attributes; }
        }
        public AttributeCollection CopyAttributes
        {
            get { return btnCopy.Attributes; }
        }
        public AttributeCollection DeleteAttributes
        {
            get { return btnDelete.Attributes; }
        }
        public AttributeCollection SearchAttributes
        {
            get { return btnSearch.Attributes; }
        }
        #endregion

        #region | Enabled | 

        public bool AddEnabled
        {
            set
            {
                btnAdd.Enabled = value;
                if (value)
                {
                    btnAdd.Style.Add("cursor", "hand");
                }
                else
                {
                    btnAdd.Style.Add("cursor", "default");
                }
            }
        }

        public bool EditEnabled
        {
            set
            {
                btnEdit.Enabled = value;
                if (value)
                {
                    btnEdit.Style.Add("cursor", "hand");
                }
                else
                {
                    btnEdit.Style.Add("cursor", "default");
                }
            }
        }

        public bool CopyEnabled
        {
            set
            {
                btnCopy.Enabled = value;
                if (value)
                {
                    btnCopy.Style.Add("cursor", "hand");
                }
                else
                {
                    btnCopy.Style.Add("cursor", "default");
                }
            }
        }

        public bool SearchEnabled
        {
            set
            {
                btnSearch.Enabled = value;
                if (value)
                {
                    btnSearch.Style.Add("cursor", "hand");
                }
                else
                {
                    btnSearch.Style.Add("cursor", "default");
                }
            }
        }

        public bool DeleteEnabled
        {
            set
            {
                btnDelete.Enabled = value;
                if (value)
                {
                    btnDelete.Style.Add("cursor", "hand");
                }
                else
                {
                    btnDelete.Style.Add("cursor", "default");
                }
            }
        }

        #endregion

        #region | CssClass |

        public string AddCssClass
        {
            get
            {
                return btnAdd.CssClass;
            }
            set
            {
                btnAdd.CssClass = value;
            }
        }

        public string EditCssClass
        {
            get
            {
                return btnEdit.CssClass;
            }
            set
            {
                btnEdit.CssClass = value;
            }
        }

        public string CopyCssClass
        {
            get
            {
                return btnCopy.CssClass;
            }
            set
            {
                btnCopy.CssClass = value;
            }
        }

        public string DeleteCssClass
        {
            get
            {
                return btnDelete.CssClass;
            }
            set
            {
                btnDelete.CssClass = value;
            }
        }

        public string SearchCssClass
        {
            get
            {
                return btnSearch.CssClass;
            }
            set
            {
                btnSearch.CssClass = value;
            }
        }

        #endregion

        private string ToolTip
        {
            set
            {
                btnAdd.ToolTip = Global.GetResource(value, "Add"); ;
                btnEdit.ToolTip = Global.GetResource(value, "Edit");
                btnCopy.ToolTip = Global.GetResource(value, "Copy");
                btnDelete.ToolTip = Global.GetResource(value, "Delete");
                btnSearch.ToolTip = Global.GetResource(value, "Search");
            }
        }

        public string Theme
        {
            set
            {
                btnAdd.Theme = value;
                btnEdit.Theme = value;
                btnCopy.Theme = value;
                btnDelete.Theme = value;
                btnSearch.Theme = value;
            }
        }

        public string Resource
        {
            set
            {
                btnAdd.Text = Global.GetResource(value, "Add");
                btnEdit.Text = Global.GetResource(value, "Edit");
                btnCopy.Text = Global.GetResource(value, "Copy");
                btnDelete.Text = Global.GetResource(value, "Delete");
                btnSearch.Text = Global.GetResource(value, "Search");
            }
        }

        #region | ClickEventHandler |
        // Event declaration
        public event AddEventHandler AddClick;
        public event EditEventHandler EditClick;
        public event CopyEventHandler CopyClick;
        public event DeleteEventHandler DeleteClick;
        public event SearchEventHandler SearchClick;
        /**/
        #endregion
        // Delegate declaration
        public delegate void AddEventHandler(object sender, EventArgs e);
        public delegate void EditEventHandler(object sender, EventArgs e);
        public delegate void CopyEventHandler(object sender, EventArgs e);
        public delegate void DeleteEventHandler(object sender, EventArgs e);
        public delegate void SearchEventHandler(object sender, EventArgs e);
        /**/
        #region | On Click |

        public void btnAdd_Click(object sender, System.EventArgs e)
        {
            if (AddClick != null)
            {
                AddClick(this, e);
            }
        }
        public void btnEdit_Click(object sender, System.EventArgs e)
        {
            if (EditClick != null)
            {
                EditClick(btnEdit, e);
            }
        }

        public void btnCopy_Click(object sender, System.EventArgs e)
        {
            if (this != null)
            {
                CopyClick(this, e);
            }
        }

        public void btnDelete_Click(object sender, System.EventArgs e)
        {
            if (DeleteClick != null)
            {
                DeleteClick(this, e);
            }
        }

        public void btnSearch_Click(object sender, System.EventArgs e)
        {
            if (SearchClick != null)
            {
                SearchClick(this, e);
            }
        }
        #endregion
    }
}